package com.zjh.photoshopstudy.Utils;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;

import com.zjh.photoshopstudy.app.video.ImageActivity;

public class CommentImageClick extends ClickableSpan {
    Context context;
    String imageUrl;

    public CommentImageClick(Context context, String imageUrl) {
        this.context = context;
        this.imageUrl = imageUrl;
    }

    @Override
    public void updateDrawState(TextPaint ds) {
        ds.setUnderlineText(false);
    }

    @Override
    public void onClick(@NonNull View view) {
        Intent intent = new Intent(context, ImageActivity.class);
        if (imageUrl.startsWith("http") || imageUrl.startsWith("content")) {
            intent.putExtra("imageUrl", imageUrl);
        } else {
            intent.putExtra("imageUrl", Data.webRoot_URL + imageUrl);
        }
        context.startActivity(intent);
    }
}
